<template>
    <el-form label-position="right" label-width="0" :model="form" style="width: 100%" ref="ruleFormRef" :rules="rules">
        <div class="bth-report" v-if="!isCheck">
            <!-- <el-button @click="goback" type="primary">返回</el-button> -->
            <el-button @click="savebg" type="primary">保存</el-button>
            <el-button @click="submitForm(ruleFormRef)" type="primary">上报</el-button>
        </div>
        <div class="table-title">
            {{ infoMsg.title }}
        </div>
        <el-table
            border
            :data="form.tableData"
            v-loading="loading"
            style="width: 98%; margin: 0 auto"
            :header-cell-style="{
                background: '#E7F2FF',
                color: 'black',
                height: '60px',
                borderBottom: '1px solid rgb(102, 102, 102)',
            }"
        >
            <el-table-column prop="s" label="代码" />
            <el-table-column prop="sn" label="名称" show-overflow-tooltip />
            <el-table-column prop="unit" label="单位" />
            <el-table-column label="2022年实际值">
                <template #default="{ row, $index }">
                    <el-form-item :prop="`tableData.${$index}.val`" :rules="rules.val">
                        <el-input
                            type="number"
                            style="width: 100%"
                            v-model="row.val"
                            :disabled="isCheck"
                            placeholder=""
                        />
                    </el-form-item>
                </template>
            </el-table-column>
            <el-table-column label="2021年核定值">
                <template #default="{ row, $index }">
                    <el-form-item :prop="`tableData.${$index}.valH`" :rules="rules.valH">
                        <el-input
                            type="number"
                            style="width: 100%"
                            v-model="row.valH"
                            :disabled="isCheck"
                            placeholder=""
                        />
                    </el-form-item>
                </template>
            </el-table-column>
            <el-table-column label="2020年实际值">
                <template #default="{ row, $index }">
                    <el-form-item :prop="`tableData.${$index}.valNine`" :rules="rules.valNine">
                        <el-input
                            type="number"
                            style="width: 100%"
                            v-model="row.valNine"
                            :disabled="isCheck"
                            placeholder=""
                        />
                    </el-form-item>
                </template>
            </el-table-column>
            <el-table-column label="2019年核定值">
                <template #default="{ row, $index }">
                    <el-form-item :prop="`tableData.${$index}.valNH`" :rules="rules.valNH">
                        <el-input
                            type="number"
                            style="width: 100%"
                            v-model="row.valNH"
                            :disabled="isCheck"
                            placeholder=""
                        />
                    </el-form-item>
                </template>
            </el-table-column>
            <el-table-column prop="code" label="证明材料编码">
                <template #default="{ row }">
                    <div class="code-box" v-if="row.code != ''">
                        <span>{{ row.code }}</span>
                        <el-tooltip class="box-item" effect="dark" :content="row.remark" placement="top">
                            <el-icon><Warning /></el-icon>
                        </el-tooltip>
                    </div>
                </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="120">
                <template #default="{ row }">
                    <el-button v-if="userRole == 3" link type="primary" size="small" @click="showDig(row, false)">
                        上传
                    </el-button>
                    <el-button link type="primary" size="small" @click="showDig(row, true)">下载</el-button>
                </template>
            </el-table-column>
        </el-table>
    </el-form>
    <el-dialog v-model="dialogVisible" title="上传" width="40%" :before-close="handleClose" style="height: auto">
        <div class="showDig">
            <div class="uploadbox">
                <el-upload
                    v-show="!isDownload"
                    class="upload-demo"
                    drag
                    action=""
                    :limit="1"
                    accept=".jpg,.jpeg,.png,.pdf,.doc,.docx, .xls,.xlsx"
                    multiple
                    :on-change="changeFile"
                    :auto-upload="false"
                    v-model:file-list="fileList"
                    :before-remove="beforeRemove"
                >
                    <img src="../../assets/container.png" />
                    <div class="bthUpload">选择文件</div>
                    <upload-filled />
                    <div class="el-upload__text">点击或将文件拖拽到这里上传</div>
                </el-upload>
                <div class="oldFile">
                    已上传文件：
                    <br />
                    <div style="margin: 10px 0" v-for="(item, index) in filesName" :key="index">
                        <span style="margin-right: 10px">{{ item.showName }}</span>
                        <el-button type="danger" @click="downFile(item)">下载</el-button>
                    </div>
                </div>
            </div>
        </div>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogVisible = false">取消</el-button>
                <el-button type="primary" @click="sureFile">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script lang="ts" setup>
import { ref, onMounted, reactive } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import {
    statisticalFindbyId,
    statisticalpublish,
    statisticalsave,
    statisticalgetProveByStaId,
    statisticalsetFile,
} from '@/util/api';
import type { FormInstance, TabsPaneContext } from 'element-plus';
import { ElMessage, ElMessageBox } from 'element-plus';
import { useStore } from '@/store';
const userRole = useStore().state.userInfo.userRole;
const ruleFormRef = ref<FormInstance>();
const loading = ref(false);
const router = useRouter();
const dataCopy: any = ref({});
const isCheck = ref(false);
const query = useRoute().query;
const form: any = ref({
    tableData: [
        {
            sort: '1',
            s: '1',
            sn: '地区生产总值（地区GDP）',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C01',
        },
        {
            sort: '2',
            s: '2',
            sn: '出口总额',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C02',
        },
        {
            sort: '3',
            s: '3',
            sn: '其中：高新技术产品出口总额',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C02',
        },
        {
            sort: '4',
            s: '4',
            sn: '进口总额',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C02',
        },
        {
            sort: '5',
            s: '5',
            sn: '其中：高新技术产品进口总额',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C02',
        },
        {
            sort: '6',
            s: '6',
            sn: '实际使用外资金额',
            unit: '万美元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C03',
        },
        {
            sort: '7',
            s: '7',
            sn: '单位土地地区生产总值产出强度',
            unit: '万元/平方公里',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '8',
            s: '1',
            sn: '地区生产总值（地区GDP）',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C01',
        },
        {
            sort: '9',
            s: '7-1',
            sn: '管辖面积',
            unit: '公顷',
            vvala: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C04',
        },
        {
            sort: '10',
            s: '8',
            sn: '劳动生产率',
            unit: '万元/人*年',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '11',
            s: '1',
            sn: '地区生产总值（地区GDP）',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C01',
        },
        {
            sort: '12',
            s: '8-1',
            sn: '“四上”企业从业人员年平均人数',
            unit: '人',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C05',
        },
        {
            sort: '13',
            s: '9',
            sn: '营业收入30(东部地区)/15(中西部地区)亿元及以上的制造业企业数量',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C06',
        },
        {
            sort: '14',
            s: '10',
            sn: '世界500强上榜企业投资研发中心、总部中心数量',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C07',
        },
        {
            sort: '15',
            s: '11',
            sn: '上市企业数量',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C08',
        },
        {
            sort: '16',
            s: '12',
            sn: '城市地下综合管廊配套能力',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '17',
            s: '12-1',
            sn: '地下综合管廊铺设里程数',
            unit: '千米',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C09',
        },
        {
            sort: '18',
            s: '12-2',
            sn: '已供地面积',
            unit: '公顷',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C09',
        },
        {
            sort: '19',
            s: '13',
            sn: '每平方公里光纤里程数',
            unit: '芯公里/平方公里',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '20',
            s: '13-1',
            sn: '光纤铺设里程数',
            unit: '芯公里',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C10',
        },
        {
            sort: '21',
            s: '13-2',
            sn: '已供地面积',
            unit: '公顷',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C09',
        },
        {
            sort: '22',
            s: '14',
            sn: '实际用于科技创新的财政支出金额',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K01',
        },
        {
            sort: '23',
            s: '15',
            sn: '规模以上工业企业研究与试验发展（R&D）经费支出占营业收入比重',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '24',
            s: '15-1',
            sn: '规模以上工业企业研究与实验发展（R&D)经费支出',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C05、K02',
        },
        {
            sort: '25',
            s: '15-2',
            sn: '规模以上工业企业营业收入',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C05',
        },
        {
            sort: '26',
            s: '16',
            sn: '职业技能培训机构数量',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K03',
        },
        {
            sort: '27',
            s: '17',
            sn: '孵化器、众创空间数量',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K04',
        },
        {
            sort: '28',
            s: '18',
            sn: '省级及以上研发机构总数',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K05',
        },
        {
            sort: '29',
            s: '18-1',
            sn: '“其中：国家级研发机构个数”',
            unit: '个',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '30',
            s: '19',
            sn: '拥有省级及以上名牌产品的企业数量',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K06',
        },
        {
            sort: '31',
            s: '20',
            sn: '高新技术企业数',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K07',
        },
        {
            sort: '32',
            s: '21',
            sn: '“四上”高新技术企业营业务收入占全区“四上”企业营业务收入的比重',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '33',
            s: '21-1',
            sn: '“四上”高新技术企业营业务收入',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K07',
        },
        {
            sort: '34',
            s: '21-2',
            sn: '全区“四上”企业营业务收入',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C05',
        },
        {
            sort: '35',
            s: '22',
            sn: '硕士及以上学历人才数量占比',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K08',
        },
        {
            sort: '36',
            s: '23',
            sn: '具有高级职称的专业技术人才占比',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K08',
        },
        {
            sort: '37',
            s: '24',
            sn: '高技能人才占比',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K08',
        },
        {
            sort: '38',
            s: '25',
            sn: '每万人口发明专利拥有量',
            unit: '件/万人',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '39',
            s: '25-1',
            sn: '发明专利拥有量',
            unit: '个',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K09',
        },
        {
            sort: '40',
            s: '25-2',
            sn: '年末“四上”企业从业人员',
            unit: '个',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C05',
        },
        {
            sort: '41',
            s: '26',
            sn: '年度PCT专利申请量',
            unit: '个',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K10',
        },
        {
            sort: '42',
            s: '27',
            sn: '年度发明专利授权量',
            unit: '个',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K09',
        },
        {
            sort: '43',
            s: '28',
            sn: '技术合同交易额',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '44',
            s: '28-1',
            sn: '技术合同交易额（科技部门）',
            unit: '元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K11',
        },
        {
            sort: '45',
            s: '28-2',
            sn: '技术合同交易额（商务部门）',
            unit: '万美元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K11',
        },
        {
            sort: '46',
            s: '29',
            sn: '地区生产总值（地区GDP）占所在地级市地区生产总值（地区GDP）比重',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '47',
            s: '1',
            sn: '地区生产总值（地区GDP）',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C01',
        },
        {
            sort: '48',
            s: '29-1',
            sn: '所在地级或以上城市地区生产总值（GDP）',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q01',
        },
        {
            sort: '49',
            s: '30',
            sn: '公共财政预算收入占所在地级市公共财政预算收入比重',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '50',
            s: '30-1',
            sn: '公共财政预算收入',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K01',
        },
        {
            sort: '51',
            s: '30-2',
            sn: '所在地级或以上城市公共财政预算收入',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q01',
        },
        {
            sort: '52',
            s: '30-3',
            sn: '经开区是否一级财政',
            unit: '是/否',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K01',
        },
        {
            sort: '53',
            s: '31',
            sn: '税收收入占所在地级市税收收入比重）',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '54',
            s: '31-1',
            sn: '税收收入',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K01',
        },
        {
            sort: '55',
            s: '32-2',
            sn: '所在地级或以上城市税收收入',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q01',
        },
        {
            sort: '56',
            s: '32',
            sn: '实际使用外资占所在地级市实际使用外资比重',
            unit: '% ',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '57',
            s: '55',
            sn: '实际使用外资金额（占比口径）',
            unit: '万美元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '58',
            s: '32-1',
            sn: '所在地级或以上城市实际使用外资额',
            unit: '万美元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q01',
        },
        {
            sort: '59',
            s: '33',
            sn: '高技术制造业营业收入占所在地级市高技术制造业营业收入比重',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '60',
            s: '33-1',
            sn: '规模以上高技术制造业营业收入',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C05',
        },
        {
            sort: '61',
            s: '33-2',
            sn: '所在地级或以上城市规模以上高技术制造业营业收入',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q01',
        },
        {
            sort: '62',
            s: '34',
            sn: '第三产业增加值占所在地级市第三产业增加值比重',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '63',
            s: '34-1',
            sn: '第三产业增加值',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C01',
        },
        {
            sort: '64',
            s: '34-2',
            sn: '所在地级或以上城市第三产业增加值',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q01',
        },
        {
            sort: '65',
            s: '35',
            sn: '设立产业引导基金、创业投资基金或其他政策性扶持基金个数',
            unit: '个',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q02',
        },
        {
            sort: '66',
            s: '36',
            sn: '企业数量增长率',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '67',
            s: '36-1',
            sn: '当年新注册企业数量',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q03',
        },
        {
            sort: '68',
            s: '36-2',
            sn: '上年末实有企业数量',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q03',
        },
        {
            sort: '69',
            s: '37',
            sn: '与其他国家级经开区合作共建的园区个数',
            unit: '个',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q04',
        },
        {
            sort: '70',
            s: '38',
            sn: '与其他地区合作共建的园区个数',
            unit: '个',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q05',
        },
        {
            sort: '71',
            s: '39',
            sn: '对口援疆、援藏、援助边境合作区个数',
            unit: '个',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q06',
        },
        {
            sort: '72',
            s: '40',
            sn: '土地开发利用率',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'Q07',
        },
        {
            sort: '73',
            s: '41',
            sn: '单位规上工业增加值能耗',
            unit: '吨标准煤/万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '74',
            s: '41-1',
            sn: '规模以上工业企业综合能源消费量',
            unit: '吨标准煤',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'S01',
        },
        {
            sort: '75',
            s: '41-2',
            sn: '规模以上工业增加值 ',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C01',
        },
        {
            sort: '76',
            s: '42',
            sn: '单位规上工业增加值水耗',
            unit: '立方米/万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '77',
            s: '42-1',
            sn: '规模以上工业企业取新水总量',
            unit: '立方米',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'S02',
        },
        {
            sort: '78',
            s: '42-2',
            sn: '规模以上工业增加值 ',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C01',
        },
        {
            sort: '79',
            s: '43',
            sn: '单位工业增加值化学需氧量（COD）排放量',
            unit: '千克/万元 ',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '80',
            s: '43-1',
            sn: '化学需氧量（COD）排放量',
            unit: '千克',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'S03',
        },
        {
            sort: '81',
            s: '43-2',
            sn: '工业增加值',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '82',
            s: '44',
            sn: '单位工业增加值二氧化硫排放量',
            unit: '千克/万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '83',
            s: '44-1',
            sn: '二氧化硫排放量',
            unit: '千克',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'S03',
        },
        {
            sort: '84',
            s: '44-2',
            sn: '工业增加值',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C01',
        },
        {
            sort: '85',
            s: '45',
            sn: '单位工业增加值氮氧化物排放量',
            unit: '千克/万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '86',
            s: '45-1',
            sn: '氮氧化物排放量',
            unit: '千克',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'S03',
        },
        {
            sort: '87',
            s: '45-2',
            sn: '工业增加值',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C01',
        },
        {
            sort: '88',
            s: '46',
            sn: '单位工业增加值氨氮排放量 ',
            unit: '千克/万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '89',
            s: '46-1',
            sn: '氨氮排放量',
            unit: '千克',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'S03',
        },
        {
            sort: '90',
            s: '46-2',
            sn: '工业增加值',
            unit: '亿元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'C01',
        },
        {
            sort: '91',
            s: '47',
            sn: '工业固体废物综合利用率',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'S03',
        },
        {
            sort: '92',
            s: '48',
            sn: '再生水（中水）回用率',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'S03',
        },
        {
            sort: '93',
            s: '49',
            sn: '通过ISO14000认证企业数',
            unit: '家',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'S04',
        },
        {
            sort: '94',
            s: '50',
            sn: '在线审批平台网址及截图',
            unit: '是/否',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'X01',
        },
        {
            sort: '95',
            s: '51',
            sn: '公共服务支出占公共财政预算支出比重',
            unit: '%',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: '',
        },
        {
            sort: '96',
            s: '51-1',
            sn: '财政支出中各项公共服务支出金额',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K01',
        },
        {
            sort: '97',
            s: '52-2',
            sn: '公共财政预算支出',
            unit: '万元',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'K01',
        },
        {
            sort: '98',
            s: '53',
            sn: '是否独立设置安全生产机构',
            unit: '是/否',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'X02',
        },
        {
            sort: '99',
            s: '54',
            sn: '是否通过ISO9001质量认证',
            unit: '是/否',
            val: '',
            valH: '',
            valNine: '',
            valNH: '',
            code: 'X03',
        },
    ],
});
const infoMsg: any = ref({});
const rules = reactive({
    val: [{ required: true, message: '请输入2020年实际值', trigger: 'blur' }],
    valH: [{ required: true, message: '请输入2020年核定值', trigger: 'blur' }],
    valNine: [{ required: true, message: '请输入2019年实际值', trigger: 'blur' }],
    valNH: [{ required: true, message: '请输入2019年核定值', trigger: 'blur' }],
});
//上传的文件列表
const fileList = ref([]);
const dialogVisible = ref<boolean>(false);
//上传的文件
const uploadFile = ref([]);
// 每行对应所需的一些其他数据
let formRestsData = reactive<Array<any>>([]);
//上传当前行 id
const setFile: any = ref('');
const filesName: any = ref([]);
// 上传文件时对应行数据
const showDigs: any = ref({});
const isDownload = ref(false);

const getTable = async () => {
    let res: any = await statisticalFindbyId(query.id);
    const { data } = (await statisticalgetProveByStaId(query.id)) as any;
    formRestsData = data;
    dataCopy.value = res.data;
    if (res.data.list != null && res.data.list != 'null') {
        form.value.tableData = JSON.parse(res.data.list);
    }
    infoMsg.value['title'] = res.data.name;
    getFormRestsData();
};
//上报
const submitForm = async (formEl: FormInstance | undefined) => {
    if (!formEl) return;
    await formEl.validate(async (valid, fields) => {
        if (!valid) return;
        dataCopy.value.list = JSON.stringify(form.value.tableData);
        let res: any = await statisticalsave(dataCopy.value);
        if (res.code == '200') {
            let rels: any = await statisticalpublish(dataCopy.value.id);
            if (rels.code == '200') {
                ElMessage.success('上报成功');
            }
        }
    });
};
//返回
const goback = () => {
    router.go(-1);
};
//保存报表
const savebg = async () => {
    dataCopy.value.list = JSON.stringify(form.value.tableData);
    let res: any = await statisticalsave(dataCopy.value);
    if (res.code == '200') {
        ElMessage.success('保存成功');
    }
};
// 给表单添加其他所需数据
const getFormRestsData = () => {
    form.value.tableData.map(i => {
        formRestsData.map(r => {
            if (i.code == r.name) {
                i.remark = r.remark;
                i.fileJson = r.fileJson;
            }
        });
    });
};
// 关闭前回调
const handleClose = (done: () => void) => {
    ElMessageBox.confirm('确定关闭弹窗?')
        .then(() => {
            dialogVisible.value = false;
        })
        .catch(() => {
            // catch error
        });
};
//上传
const showDig = async (item: any, bool: boolean) => {
    //清除上一个上传的
    uploadFile.value = [];
    fileList.value = [];
    showDigs.value = item;
    dialogVisible.value = true;
    setFile.value = item.id;
    isDownload.value = bool;

    if (!item.fileJson) {
        filesName.value = [];
    } else {
        filesName.value = JSON.parse(item.fileJson);
    }
};
// 获取文件名字和地址
const changeFile = (file: any) => {
    uploadFile.value.push(file.raw);
};
//删除文件
const beforeRemove = (file: any, uploadFiles: any) => {
    uploadFile.value.forEach((item: any, index: any) => {
        if (item.uid == file.raw.uid) uploadFile.value.splice(index, 1);
    });
};
//确定上传
const sureFile = async () => {
    if (uploadFile.value.length <= 0) return;
    let formdata = new FormData();
    uploadFile.value.forEach((item: any) => {
        formdata.append('files', item);
    });
    formdata.append('id', query.id);
    formdata.append('type', showDigs.value.code);
    let res = await statisticalsetFile(formdata);
    console.log(res);
    if (res) {
        if (showDigs.value.files == null) {
            showDigs.value.files = '';
            showDigs.value.files += res;
        } else {
            showDigs.value.files = showDigs.value.files + ';' + res;
        }
        dialogVisible.value = false;
        getTable();
        ElMessage.success('上传成功');
    }
};
//下载附件
const downFile = async (item: any) => {
    let link = document.createElement('a');
    link.style.display = 'none';
    link.href = '/api/file/show/' + item.saveName;
    link.download = item.showName;
    link.click();
    window.URL.revokeObjectURL(link.href);
};
onMounted(() => {
    if (query.isCheck) {
        isCheck.value = true;
    } else {
        isCheck.value = false;
    }
    getTable();
});
</script>
<style scoped>
.table-title {
    width: 98%;
    margin: 0 auto;
    text-align: center;
    font-size: 24px;
    background-color: #ff0000;
    line-height: 50px;
    color: #ffffff;
    border-bottom: 1px solid rgb(102, 102, 102);
}
.bth-report {
    width: 98%;
    display: flex;
    justify-content: right;
    margin: 40px 0;
}
.code-box {
    display: flex;
    align-items: center;
    gap: 8px;
}
.uploadbox {
    width: 100%;
    margin: 20px;
    margin-right: 20px;
    display: flex;
    .oldFile {
        margin-left: 20px;
    }
}
.showDig {
    display: flex;
}
</style>
